package com.info.zhiduoduo.repository.mapper.system;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.system.CityCategoryDto;
import com.info.zhiduoduo.repository.dto.system.CityCategoryOneDto;
import com.info.zhiduoduo.repository.entity.system.CityInvoiceCategory;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CityInvoiceCategoryMapper extends BaseMapper<CityInvoiceCategory> {



    // 查询 一级分类列表
    @Select(" select sc.* , cc.name as cityName from zdd_system_citycategory sc LEFT JOIN zdd_crowdsource_city_config cc ON sc.city_id = cc.id " +
            " where 1 = 1 and sc.parentid = 0 and sc.deleted = 0 " +
            " ${whereStr}  order by sc.createtime desc  ")
    List<CityCategoryOneDto> queryCityCategoryOneList(@Param("whereStr") String whereStr);


    // 查询 一级列表
    @Select(" select * from  zdd_system_citycategory  where parentid = 0 and deleted = 0 " +
            " AND IF( ISNULL(#{cityId}) , 1=1 , city_id = #{cityId}  ) " +
            " AND IF( ISNULL(#{categoryName}) OR #{categoryName} = '' , 1 = 1 , name like '%${categoryName}%' )  " +
            " order by createtime desc ")
    List<CityCategoryDto> selectCityCategoryList(@Param("cityId") Integer cityId, @Param("categoryName") String categoryName);

    // 查询 二级列表
    @Select(" select * from  zdd_system_citycategory  where parentid = #{parentid} and deleted = 0 ")
    List<CityCategoryDto> selectCityCategoryByTwoList(int parentid);



}
